package com.young.operation.controller;

import com.young.common.interf.IBaseController;
import com.young.common.model.ResultData;
import com.young.operation.service.DeptService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("dept")
@RestController
@Slf4j
@RequiredArgsConstructor
public class DeptController implements IBaseController {

    private final DeptService deptService;

    @GetMapping
    ResultData<?> queryList(
            @RequestParam(required = false) String name,
            @RequestParam(required = false) Integer pageNum,
            @RequestParam(required = false) Integer pageSize
    ) {
        pageNum = null == pageNum ? DEFAULT_PAG_ENUM : pageNum;
        pageSize = null == pageSize ? DEFAULT_PAGE_SIZE : pageSize;
        return success(deptService.queryPage(name, pageNum, pageSize));
    }
}
